package com.miyu.common.utils.taskJob;

import com.alibaba.fastjson.JSONObject;
import com.miyu.common.utils.magic.GetBeanUtil;
import com.miyu.common.utils.redis.redisUtils.util.RedisListUtil;
import com.miyu.common.utils.web.PropertiesUtil;

import java.util.concurrent.Callable;

public class AopTaskCache implements Callable<JSONObject> {

    private JSONObject param;
    /*是否启动redis*/
    static String isRedis= PropertiesUtil.getProperty("spring.redis.enable");
    static RedisListUtil rv = GetBeanUtil.getBeanByClass(RedisListUtil.class);
    @Override
    public JSONObject call() throws Exception {

        if(isRedis.equals("true")){
            if(param.containsKey("cosApiLog")) {
                rv.insert(1,"cosApiLog",param.getJSONObject("cosApiLog"));
            } else if(param.containsKey("cosLoginLog")){
                rv.insert(1,"cosLoginLog",param.getJSONObject("cosLoginLog"));
            }
        }

        return null;
    }

    public AopTaskCache(JSONObject param){
        this.param=param;
    }
}
